﻿using DataModels.Dto;
using DataModels.Dto.NeighborCircle;
using DataModels.Entities.AuthCore;
using DataModels.Entities.Base;
using DataModels.Entities.NeighborCircle;
using DataModels.Enums.NeighborCircle;
using SqlSugar;
using System.Security.Policy;
using Utils;
using static DataModels.Enums.GeneralEnum;

namespace Services.NeighborCircle
{
    public class NeighborCircleForumPostService(SqlSugarClient db) : BaseService(db)
    {
        /// <summary>
        /// 获取话题列表
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPostTalk(NeighborCircleForumPostType? PostType, Guid? NeighborCircleForumPostCategoryUUID, Guid? NeighborCircleForumPostCategorySubUUID)
        {
            List<NeighborCircleForumPostTalk> res = await db.Queryable<NeighborCircleForumPostTalk>()
                .WhereIF(PostType.HasValue, ncfpt => ncfpt.PostType == PostType)
                .WhereIF(NeighborCircleForumPostCategoryUUID.HasValue, ncfpt => ncfpt.NeighborCircleForumPostCategoryUUID == NeighborCircleForumPostCategoryUUID)
                .WhereIF(NeighborCircleForumPostCategorySubUUID.HasValue, ncfpt => ncfpt.NeighborCircleForumPostCategorySubUUID == NeighborCircleForumPostCategorySubUUID)
                .OrderBy(ncfpt => ncfpt.Sort)
                .ToListAsync();
            return Success(res);
        }

        /// <summary>
        /// 获取分类
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPostCategory(NeighborCircleForumPostType? PostType)
        {
            // 执行基础查询，获取扁平化数据
            var query = await db.Queryable<NeighborCircleForumPostCategory, NeighborCircleForumPostCategorySub>((ncfpc, ncfpcs) => new JoinQueryInfos(
                    JoinType.Left, ncfpc.UUID == ncfpcs.NeighborCircleForumPostCategoryUUID
                ))
                .OrderBy(ncfpc => ncfpc.Sort)
                // 筛选类型
                .WhereIF(PostType.HasValue, ncfpc => ncfpc.PostType == PostType)
                .Select((ncfpc, ncfpcs) => new
                {
                    CategoryId = ncfpc.UUID,
                    CategoryName = ncfpc.Name,
                    CategoryIcon = ncfpc.Url,
                    SubCategoryId = ncfpcs == null ? Guid.Empty : ncfpcs.UUID,
                    SubCategoryName = ncfpcs.Name,
                    SubCategoryIcon = ncfpcs.Url,
                    SubCategorySort = ncfpcs.Sort
                })
                .ToListAsync();

            // 在内存中构建树形结构
            var result = query
                .GroupBy(x => new { x.CategoryId, x.CategoryName, x.CategoryIcon })
                .Select(g => new
                {
                    CategoryId = g.Key.CategoryId,
                    CategoryName = g.Key.CategoryName,
                    CategoryIcon = g.Key.CategoryIcon,
                    SubCategories = g
                        .Where(x => x.SubCategoryId != Guid.Empty)
                        .OrderBy(x => x.SubCategorySort)
                        .Select(x => new
                        {
                            SubCategoryId = x.SubCategoryId,
                            SubCategoryName = x.SubCategoryName,
                            SubCategoryIcon = x.SubCategoryIcon
                        })
                        .ToList()
                })
                .ToList();

            return Success(result);
        }

        /// <summary>
        /// 获取活动列表
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPostActivities()
        {
            List<NeighborCircleForumPostActivities> ncfpas = await db.Queryable<NeighborCircleForumPostActivities>()
                .Where(ncfpa => ncfpa.IsDeleted == Status.Disable)
                .ToListAsync()
                ;
            return Success(ncfpas);
        }

        /// <summary>
        /// 获取帖子列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPost(GetNeighborCircleForumPostInfo info)
        {
            RefAsync<int> total = 0;
            var query = db.Queryable<NeighborCircleForumPost, User>((ncfp, u) => new JoinQueryInfos(
                    JoinType.Left, ncfp.CreateUserUUID == u.UUID
                ))
                .Where(ncfp => ncfp.IsDeleted == Status.Disable);

            // 分条件添加复杂查询逻辑
            if (info.ProjectUUID.HasValue)
            {
                query = query.Where(ncfp =>
                    ncfp.PostStatus == NeighborCircleForumPostStatus.Open ||
                    (ncfp.PostStatus == NeighborCircleForumPostStatus.Limitation &&
                     ncfp.ProjectUUID == info.ProjectUUID.Value));
            }
            else
            {
                query = query.Where(ncfp => ncfp.PostStatus == NeighborCircleForumPostStatus.Open);
            }

            // 添加其他条件
            query = query
                .WhereIF(info.NeighborCircleForumPostCategoryUUID.HasValue, ncfp => ncfp.NeighborCircleForumPostCategoryUUID == info.NeighborCircleForumPostCategoryUUID)
                .WhereIF(info.NeighborCircleForumPostCategorySubUUID.HasValue, ncfp => ncfp.NeighborCircleForumPostCategorySubUUID == info.NeighborCircleForumPostCategorySubUUID)
                .WhereIF(info.NeighborCircleForumPostTalkUUID.HasValue, ncfp => ncfp.NeighborCircleForumPostTalkUUID == info.NeighborCircleForumPostTalkUUID)
                .WhereIF(info.PostType.HasValue, ncfp => ncfp.PostType == info.PostType)
                .WhereIF(info.IsRecommend.HasValue, ncfp => ncfp.IsRecommend == info.IsRecommend)
                .WhereIF(info.UserUUID.HasValue, ncfp => ncfp.CreateUserUUID == info.UserUUID)
                ;

            // 执行查询
            var res = await query
                .Select((ncfp, u) => new GetNeighborCircleForumPostDto
                {
                    UUID = ncfp.UUID,
                    Title = ncfp.Title,
                    PostType = ncfp.PostType,
                    Content = ncfp.Content,
                    ShareCount = ncfp.ShareCount,
                    LikeCount = ncfp.LikeCount,
                    CommentCount = ncfp.CommentCount,
                    AvatarUrl = u.AvatarUrl,
                    DisplayName = u.DisplayName
                })
                .ToPageListAsync(info.PageNumber, info.PageSize, total);

            foreach (var item in res)
            {
                item.Urls = GetAttachment(item.UUID);
            }

            return PageSuccess(info.PageNumber, info.PageSize, total, res);
        }

        /// <summary>
        /// 获取帖子详情
        /// </summary>
        /// <param name="NeighborCircleForumPostUUID"></param>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPostDetail(Guid NeighborCircleForumPostUUID)
        {
            GetNeighborCircleForumPostDetailDto res = await db.Queryable<NeighborCircleForumPost, User, Projects>((ncfp, u, p) => new JoinQueryInfos(
                        JoinType.Left, ncfp.CreateUserUUID == u.UUID,
                        JoinType.Left, ncfp.ProjectUUID == p.UUID
                    ))
                    .Where(ncfp => ncfp.IsDeleted == Status.Disable)
                    .Where(ncfp => ncfp.UUID == NeighborCircleForumPostUUID)
                    .Select((ncfp, u, p) => new GetNeighborCircleForumPostDetailDto
                    {
                        UUID = ncfp.UUID,
                        NeighborCircleForumPostTalkUUID = ncfp.NeighborCircleForumPostTalkUUID,
                        NeighborCircleForumPostActivitiesUUID = ncfp.NeighborCircleForumPostActivitiesUUID,
                        ProjectName = p.ProjectName,
                        AvatarUrl = u.AvatarUrl,
                        DisplayName = u.DisplayName,
                        Content = ncfp.Content,
                        ShareCount = ncfp.ShareCount,
                        LikeCount = ncfp.LikeCount,
                        CommentCount = ncfp.CommentCount,
                        CreateTime = ncfp.CreateTime
                    })
                    .FirstAsync()
                    ;
            if (res == null)
            {
                return Error("帖子不存在");
            }



            NeighborCircleForumPostWant ncfpw = await db.Queryable<NeighborCircleForumPostWant>()
                .Where(ncfpw => ncfpw.IsDeleted == Status.Disable)
                .Where(ncfpw => ncfpw.CreateUserUUID == UserUUID)
                .Where(ncfpw => ncfpw.NeighborCircleForumPostUUID == res.UUID)
                .FirstAsync()
                ;

            NeighborCircleLikes ncl = await db.Queryable<NeighborCircleLikes>()
                .Where(ncl => ncl.IsDeleted == Status.Disable)
                .Where(ncl => ncl.CreateUserUUID == UserUUID)
                .Where(ncl => ncl.NeighborCircleForumUUID == res.UUID)
                .FirstAsync()
                ;

            res.IsWant = ncfpw == null ? Status.Disable : Status.Enable;
            res.IsLike = ncl == null ? Status.Disable : Status.Enable;
            res.Urls = GetAttachment(res.UUID);
            return Success(res);
        }

        /// <summary>
        /// 获取点赞列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPostLikes(GetNeighborCircleForumPostLikesInfo info)
        {
            RefAsync<int> total = 0;

            var res = await db.Queryable<NeighborCircleLikes, User>((ncl, u) => new JoinQueryInfos(
                    JoinType.Left, ncl.CreateUserUUID == u.UUID
                ))
                .Where(ncl => ncl.IsDeleted == Status.Disable)
                .Where(ncl => ncl.NeighborCircleForumUUID == info.NeighborCircleForumPostUUID)
                .Select((ncl, u) => new
                {
                    u.AvatarUrl,
                    u.DisplayName,
                    ncl.CreateTime
                })
                .ToPageListAsync(info.PageNumber, info.PageSize, total);

            return PageSuccess(info.PageNumber,info.PageSize,total, res);
        }

        /// <summary>
        /// 获取评论
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<ResponseModel> GetNeighborCircleForumPostComment(GetNeighborCircleForumPostCommentInfo info)
        {
            RefAsync<int> total = 0;

            List<GetNeighborCircleForumPostCommentDto> res = await db.Queryable<NeighborCircleConments, User>((ncc, u) => new JoinQueryInfos(
                    JoinType.Left, ncc.CreateUserUUID == u.UUID
                ))
                .Where(ncc => ncc.IsDeleted == Status.Disable)
                .Where(ncc => ncc.NeighborCircleForumUUID == info.NeighborCircleForumPostUUID)
                .Where(ncc => ncc.ParentCommentUUID == Guid.Empty || ncc.ParentCommentUUID == null)
                .Select((ncc,u) => new GetNeighborCircleForumPostCommentDto
                {
                    UUID = ncc.UUID,
                    AvatarUrl = u.AvatarUrl,
                    DisplayName = u.DisplayName,
                    Content = ncc.Content,
                    CreateTime = ncc.CreateTime
                })
                .ToPageListAsync(info.PageNumber, info.PageSize, total);
                ;
            List<Guid> nccuuid = [.. res.Select(x => x.UUID)];

            List<NeighborCircleLikes> ncls = await db.Queryable<NeighborCircleLikes>()
                .Where(ncl => ncl.IsDeleted == Status.Disable)
                .Where(ncl => nccuuid.Contains(ncl.NeighborCircleForumUUID))
                .ToListAsync()
                ;

            foreach (var item in res)
            {
                item.LikeCount = ncls.Where(x => x.NeighborCircleForumUUID == item.UUID).Count();
                item.IsLike = ncls.Where(x => x.NeighborCircleForumUUID == item.UUID && x.CreateUserUUID == UserUUID).Count() > 0 ? Status.Enable : Status.Disable;
                item.SubComment = await GetNeighborCircleForumPostCommentSub(item.UUID);
            }

            return PageSuccess(info.PageNumber, info.PageSize, total, res);
        }

        /// <summary>
        /// 获取子评论
        /// </summary>
        /// <param name="ParentCommentUUID"></param>
        /// <returns></returns>
        private async Task<List<GetNeighborCircleForumPostCommentDto>> GetNeighborCircleForumPostCommentSub(Guid ParentCommentUUID)
        {
            List<GetNeighborCircleForumPostCommentDto> res = await db.Queryable<NeighborCircleConments, User>((ncc, u) => new JoinQueryInfos(
                    JoinType.Left, ncc.CreateUserUUID == UserUUID
                ))
                .Where(ncc => ncc.ParentCommentUUID == ParentCommentUUID)
                //.Where(ncc => ncc.ParentCommentUUID != Guid.Empty && ncc.ParentCommentUUID != null)
                .Where(ncc => ncc.IsDeleted == Status.Disable)
                .Select((ncc, u) => new GetNeighborCircleForumPostCommentDto
                {
                    UUID = ncc.UUID,
                    AvatarUrl = u.AvatarUrl,
                    DisplayName = u.DisplayName,
                    Content = ncc.Content,
                    CreateTime = ncc.CreateTime
                })
                .ToListAsync()
            ;
            if(res.Count == 0)
            {
                return res;
            }

            List<Guid> nccuuid = [.. res.Select(x => x.UUID)];

            List<NeighborCircleLikes> ncls = await db.Queryable<NeighborCircleLikes>()
                .Where(ncl => ncl.IsDeleted == Status.Disable)
                .Where(ncl => nccuuid.Contains(ncl.NeighborCircleForumUUID))
                .ToListAsync()
                ;

            foreach (var item in res)
            {
                item.LikeCount = ncls.Where(x => x.NeighborCircleForumUUID == item.UUID).Count();
                item.IsLike = ncls.Count(x => x.NeighborCircleForumUUID == item.UUID && x.CreateUserUUID == UserUUID) > 0 ? Status.Enable : Status.Disable;
                item.SubComment = await GetNeighborCircleForumPostCommentSub(item.UUID);
            }

            return res;
        }

        /// <summary>
        /// 帖子点赞/取消点赞
        /// </summary>
        /// <param name="NeighborCircleForumPostUUID"></param>
        /// <returns></returns>
        public async Task<ResponseModel> NeighborCircleForumPostLike(Guid NeighborCircleForumPostUUID)
        {
            try
            {
                await db.BeginTranAsync();
                var temp = await db.Queryable<NeighborCircleForumPost, NeighborCircleLikes>((ncf, ncl) => new JoinQueryInfos(
                        JoinType.Left, ncf.UUID == ncl.NeighborCircleForumUUID && ncl.IsDeleted == Status.Disable && ncl.CreateUserUUID == UserUUID
                    ))
                    .Where(ncf => ncf.IsDeleted == Status.Disable)
                    .Where(ncf => ncf.UUID == NeighborCircleForumPostUUID)
                    .Select((ncf, ncl) => new
                    {
                        ncf,
                        ncl,
                        ncluuid = ncl.UUID,
                    })
                    .FirstAsync()
                    ;
                if (temp == null)
                {
                    return Error("帖子不存在");
                }
                if (temp.ncluuid == Guid.Empty)
                {
                    NeighborCircleLikes ncl = new()
                    {
                        NeighborCircleForumUUID = temp.ncf.UUID,
                        CreateUserUUID = UserUUID
                    };
                    await db.Insertable(ncl).ExecuteCommandAsync();

                    temp.ncf.LikeCount += 1;

                    await db.Updateable(temp.ncf).ExecuteCommandAsync();

                    await db.CommitTranAsync();
                    return Success("点赞成功");
                }
                else
                {
                    temp.ncl.IsDeleted = Status.Enable;

                    await db.Updateable(temp.ncl).ExecuteCommandAsync();

                    temp.ncf.LikeCount -= 1;

                    await db.Updateable(temp.ncf).ExecuteCommandAsync();

                    await db.CommitTranAsync();
                    return Success("已取消点赞");
                }
            }
            catch (Exception)
            {
                await db.RollbackTranAsync();
                return Error("操作失败");
            }
        }

        /// <summary>
        /// 评论点赞/取消点赞
        /// </summary>
        /// <param name="NeighborCircleForumPostCommentUUID"></param>
        /// <returns></returns>
        public async Task<ResponseModel> NeighborCircleForumPostCommentLike(Guid NeighborCircleForumPostCommentUUID)
        {
            var ncc = await db.Queryable<NeighborCircleConments, NeighborCircleLikes>((ncc, ncl) => new JoinQueryInfos(
                    JoinType.Left,ncc.UUID == ncl.NeighborCircleForumUUID && ncl.IsDeleted == Status.Disable && ncl.CreateUserUUID == UserUUID
                ))
                .Where(ncc => ncc.IsDeleted == Status.Disable)
                .Where(ncc => ncc.UUID == NeighborCircleForumPostCommentUUID)
                .Select((ncc, ncl) => new
                {
                    ncc.UUID,
                    ncl,
                    ncluuid = ncl.UUID,
                })
                .FirstAsync()
                ;
            if(ncc == null)
            {
                return Error("评论不存在");
            }
            if(ncc.ncluuid == Guid.Empty)
            {
                NeighborCircleLikes ncl = new()
                {
                    NeighborCircleForumUUID = ncc.UUID,
                    CreateUserUUID = UserUUID
                };
                await db.Insertable(ncl).ExecuteCommandAsync();

                await db.CommitTranAsync();
                return Success("点赞成功");
            }
            else
            {
                ncc.ncl.IsDeleted = Status.Enable;
                await db.Updateable(ncc.ncl).ExecuteCommandAsync();

                await db.CommitTranAsync();
                return Success("已取消点赞");
            }
        }

        /// <summary>
        /// 发布评论
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<ResponseModel> CreateNeighborCircleForumPostComment(CreateNeighborCircleForumPostCommentInfo info)
        {
            try
            {
                await db.BeginTranAsync();
                NeighborCircleForumPost ncfp = await db.Queryable<NeighborCircleForumPost>()
                    .Where(ncfp => ncfp.IsDeleted == Status.Disable)
                    .Where(ncfp => ncfp.UUID == info.NeighborCircleForumPostUUID)
                    .FirstAsync()
                    ;
                if (ncfp == null)
                {
                    return Error("帖子不存在");
                }
                NeighborCircleConments ncc = new()
                {
                    NeighborCircleForumUUID = ncfp.UUID,
                    ParentCommentUUID = info.ParentCommentUUID,
                    Content = info.Content
                };
                ncfp.CommentCount += 1;

                await db.Insertable(ncc).ExecuteCommandAsync();

                await db.Updateable(ncfp).ExecuteCommandAsync();

                await db.CommitTranAsync();
                return Success();

            }
            catch (Exception ex)
            {
                await db.RollbackTranAsync();
                return Error("评论失败");
            }
        }

        /// <summary>
        /// 分享次数+1
        /// </summary>
        /// <param name="NeighborCircleForumPostUUID"></param>
        /// <returns></returns>
        public async Task<ResponseModel> NeighborCircleForumPostShare(Guid NeighborCircleForumPostUUID)
        {
            NeighborCircleForumPost ncfp = await db.Queryable<NeighborCircleForumPost>()
                .Where(ncfp => ncfp.IsDeleted == Status.Disable)
                .Where(ncfp => ncfp.UUID == NeighborCircleForumPostUUID)
                .FirstAsync()
                ;
            if(ncfp == null)
            {
                return Error("帖子不存在");
            }
            ncfp.ShareCount += 1;
            await db.Updateable(ncfp).ExecuteCommandAsync();
            return Success();
        }

        /// <summary>
        /// 发帖
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<ResponseModel> CreateNeighborCircleForumPost(CreateNeighborCircleForumPostInfo info)
        {
            try
            {
                await db.BeginTranAsync();

                if (info.NeighborCircleForumPostActivitiesUUID.HasValue)
                {
                    if (info.PostType == NeighborCircleForumPostType.TalentShow)
                    {
                        await CkActivities((Guid)info.NeighborCircleForumPostActivitiesUUID);
                    }
                    else
                    {
                        await db.RollbackTranAsync();
                        return Error($"{NeighborCircleForumPostType.TalentShow.GetDescription()} 才能参加活动");
                    }

                }
                NeighborCircleForumPost ncfp = new()
                {
                    CreateUserUUID = UserUUID,
                    ProjectUUID = info.ProjectUUID,
                    NeighborCircleForumPostCategoryUUID = info.NeighborCircleForumPostCategoryUUID,
                    NeighborCircleForumPostCategorySubUUID = info.NeighborCircleForumPostCategorySubUUID,
                    NeighborCircleForumPostTalkUUID = info.NeighborCircleForumPostTalkUUID,
                    NeighborCircleForumPostActivitiesUUID = info.NeighborCircleForumPostActivitiesUUID,
                    Title = info.Title,
                    Content = info.Content,
                    Latitude = info.Latitude,
                    Longitude = info.Longitude,
                    PostStatus = info.IsLimit.HasValue && info.IsLimit.Value == Status.Enable ? NeighborCircleForumPostStatus.Limitation : NeighborCircleForumPostStatus.Open,
                    PostType = info.PostType
                };

                ncfp = await db.Insertable(ncfp).ExecuteReturnEntityAsync();

                if(info.PostType == NeighborCircleForumPostType.SecondHand)
                {
                    if (string.IsNullOrEmpty(info.ExtendJson))
                    {
                        await db.RollbackTranAsync();
                        return Error("二手交易必须填写联系信息");
                    }
                    NeighborCircleForumPostSecondHand ncfpsh = new()
                    {
                        NeighborCircleForumPostUUID = ncfp.UUID,
                        ExtendJson = info.ExtendJson,
                        CreateUserUUID = UserUUID
                    };

                    await db.Insertable(ncfpsh).ExecuteReturnEntityAsync();
                }

                await SetAttachmentAsync(ncfp.UUID, info.Urls);

                return Success();
            }
            catch (MSGException ex)
            {
                await db.RollbackTranAsync();
                return Error(ex.Message);
            }
            catch (Exception)
            {
                await db.RollbackTranAsync();
                return Error("发布失败");
            }
        }

        /// <summary>
        /// 检查活动
        /// </summary>
        /// <param name="NeighborCircleForumPostActivitiesUUID"></param>
        /// <returns></returns>
        /// <exception cref="MSGException"></exception>
        private async Task<Boolean> CkActivities(Guid NeighborCircleForumPostActivitiesUUID)
        {
            NeighborCircleForumPostActivities ncfpa = await db.Queryable<NeighborCircleForumPostActivities>()
                .Where(ncfpa => ncfpa.IsDeleted == Status.Disable)
                .Where(ncfpa => ncfpa.StartTime <= DateTime.Now)
                .Where(ncfpa => ncfpa.EndTime >= DateTime.Now)
                .Where(ncfpa => ncfpa.UUID == NeighborCircleForumPostActivitiesUUID)
                .FirstAsync()
                ;
            return ncfpa == null ? throw new MSGException("活动不存在或不在开启时间内") : true;
        }

        /// <summary>
        /// 想要二手商品
        /// </summary>
        /// <param name="NeighborCircleForumPostUUID"></param>
        /// <returns></returns>
        public async Task<ResponseModel> NeighborCircleForumPostWant(Guid NeighborCircleForumPostUUID)
        {
            NeighborCircleForumPost ncfp = await db.Queryable<NeighborCircleForumPost>()
                .Where(ncfp => ncfp.IsDeleted == Status.Disable)
                .Where(ncfp => ncfp.PostType == NeighborCircleForumPostType.SecondHand)
                .Where(ncfp => ncfp.UUID == NeighborCircleForumPostUUID)
                .FirstAsync()
                ;
            if (ncfp == null)
            {
                return Error("想要的商品不存在");
            }

            NeighborCircleForumPostWant ckncfpw = await db.Queryable<NeighborCircleForumPostWant>()
                .Where(ncfpw => ncfpw.IsDeleted == Status.Disable)
                .Where(ncfpw => ncfpw.CreateUserUUID == UserUUID)
                .FirstAsync()
                ;

            if(ckncfpw == null)
            {
                NeighborCircleForumPostWant ncfpw = new()
                {
                    NeighborCircleForumPostUUID = ncfp.UUID,
                    CreateUserUUID = UserUUID,
                };
                await db.Insertable(ncfpw).ExecuteCommandAsync();
                return Success("对方同意后即可获得Ta的联系信息");
            }
            else
            {
                ckncfpw.IsDeleted = Status.Enable;
                await db.Updateable(ckncfpw).ExecuteCommandAsync();
                return Success("已取消想要");
            }
        }
    }
}
